package com.lhy.mymall.controller;

import com.github.pagehelper.PageInfo;
import com.lhy.mymall.common.ApiRestResponse;
import com.lhy.mymall.exception.MallException;
import com.lhy.mymall.service.OrderService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: 卢辉宇
 * @date: 2022/12/21 14:12
 * @description: 后台管理controller
 */
@RestController
@RequestMapping("/admin/order")
public class OrderAdminController {

    @Resource
    OrderService orderService;

    /**
     * 管理员后台订单列表
     * @param pageNum
     * @param pageSize
     * @return
     */
    @PostMapping("/list")
    public ApiRestResponse listForAdmin(Integer pageNum,Integer pageSize) throws MallException {
        //调用service层的管理员列表方法。。。
        PageInfo pageInfo = orderService.listForAdmin(pageNum, pageSize);

        return ApiRestResponse.success(pageInfo);
    }

    /**
     * 发货接口
     * @param orderNo
     * @return
     * @throws MallException
     */
    @PostMapping("/delivered")
    public ApiRestResponse delivered(String orderNo) throws MallException {
        //调用service层的发货方法。。。
        orderService.delivered(orderNo);

        return ApiRestResponse.success();
    }

}
